package avicit.bdp.dds.api.utils;

/**
 * TODO
 *
 * @author xugb
 * @date 2022/6/15 20:13
 */
public class TaskStateUtils {
    /**
     * 任务状态切换
     *
     * @param	state
     * @return int
     *
     */
    public static int convertTaskState(int state) {
        //流程实例状态 ：0--提交成功；1--运行中；2--准备暂停；3--暂停
        //            4-准备停止；5--停止；6--失败；7--成功；8-需要容错；9-kill，10-等待线程；
        //            11-等待依赖加载
        //返回状态  0--未运行；1--运行中；2--失败；3--成功
        int newstate = 0;
        switch (state) {
            case 1:
                newstate = 1;
                break;
            case 6:
                newstate = 2;
                break;
            case 7:
                newstate = 3;
                break;
            default:
                newstate = 0;

        }

        return newstate;
    }

    /**
     * 任务状态切换
     *
     * @param	state
     * @return String
     *
     */
    public static String convertStateName(int state) {
        String name = "未运行";
        switch (state) {
            case 0:
                name = "未运行";
                break;
            case 1:
                name = "运行中";
                break;
            case 2:
                name = "失败";
                break;
            case 3:
                name = "成功";
                break;
            default:
                name = "未运行";

        }

        return name;
    }
}
